package com.senlingspace.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjStoreCostMarketing;
import com.senlingspace.system.service.ISlkjStoreCostMarketingService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 营销成本明细Controller
 *
 * @author SenlingSpace
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/system/marketing")
public class SlkjStoreCostMarketingController extends BaseController
{
    @Autowired
    private ISlkjStoreCostMarketingService slkjStoreCostMarketingService;

    /**
     * 查询营销成本明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlkjStoreCostMarketing slkjStoreCostMarketing) {
        PageInfo<SlkjStoreCostMarketing> list = slkjStoreCostMarketingService.selectSlkjStoreCostMarketingList(slkjStoreCostMarketing,true);
        return getDataTable(list);
    }

    /**
     * 导出营销成本明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:export')")
    @Log(title = "营销成本明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlkjStoreCostMarketing slkjStoreCostMarketing) {
        PageInfo<SlkjStoreCostMarketing> list = slkjStoreCostMarketingService.selectSlkjStoreCostMarketingList(slkjStoreCostMarketing,false);
        ExcelUtil<SlkjStoreCostMarketing> util = new ExcelUtil<SlkjStoreCostMarketing>(SlkjStoreCostMarketing.class);
        util.exportExcel(response, list.getList(), "营销成本明细数据");
    }

    /**
     * 获取营销成本明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slkjStoreCostMarketingService.selectSlkjStoreCostMarketingById(id));
    }

    /**
     * 新增营销成本明细
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:add')")
    @Log(title = "营销成本明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjStoreCostMarketing slkjStoreCostMarketing)
    {
        return toAjax(slkjStoreCostMarketingService.insertSlkjStoreCostMarketing(slkjStoreCostMarketing));
    }

    /**
     * 修改营销成本明细
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:edit')")
    @Log(title = "营销成本明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjStoreCostMarketing slkjStoreCostMarketing)
    {
        return toAjax(slkjStoreCostMarketingService.updateSlkjStoreCostMarketing(slkjStoreCostMarketing));
    }

    /**
     * 删除营销成本明细
     */
    @PreAuthorize("@ss.hasPermi('system:marketing:remove')")
    @Log(title = "营销成本明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slkjStoreCostMarketingService.deleteSlkjStoreCostMarketingByIds(ids));
    }
}
